#_*_coding:utf-8_*_
import json
import os
import sys
import psycopg2
import sql
import model
reload(sys)
sys.setdefaultencoding('utf-8')


files = os.listdir('/home/ypc/temp/mapcms/mapdata/geometryProvince/')
for file in files:
 try:
  f = '/home/ypc/temp/mapcms/mapdata/geometryProvince/'+file
 # s = json.load(f)
  model.add_city(f)
  #nums =  s['features']

  #for num in nums:
    #print num['geometry']['type']
    #print num['geometry']['coordinates']
    #print num['properties']['name']
    #conn = psycopg2.connect(database="postgres", user="postgres", password="root", host="localhost", port="5432")
    #cur = conn.cursor()
    #print 1
   # cur.execute("INSERT INTO area(internal_name,level,geom_type,coordinates)VALUES(%s,%d,%s,%s)", (num['properties']['name'],3,num['geometry']['type'],num['geometry']['coordinates']))
    #print num['geometry']['type']

   # conn.commit()
   # cur.close()
   # conn.close()
 # f.close()
 except ValueError:
  pass
 else:
  pass
